<template>
  <div>
    <h2 class="margin-bom title">{{title}}</h2>
    <el-table :data="manages" :stripe="true" style="width: 80% ;margin:0 auto;min-width:921px;">
      <el-table-column type="index" label="序号" width="150"></el-table-column>
      <el-table-column prop="name" label="名称"></el-table-column>
      <el-table-column prop="prop" label="属性"></el-table-column>
      <el-table-column prop="time" label="时间"></el-table-column>
      <el-table-column prop label="操作">
        <template slot-scope="scope">
          <el-button type="primary" @click="updateManage(scope.row.id)">编辑</el-button>
          <v-del :delId="scope.row.id" @del="del($event)"></v-del>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import ajax from "../../common/js/ajax";
import API from "../../common/js/api";
export default {
  data() {
    return {
      title: "管理员列表",
      manages: [],
      delId: ""
    };
  },
  methods: {
    handleClick(row) {
      alert(row);
    },
    updateManage(id) {
      this.$router.push("/index/manageCreate?id=" + id);
    },
    del(id) {
      ajax(
        API.delManage,
        "get",
        { id },
        d => {
          this.$message({
            type: "success",
            message: "删除成功"
          });
          this.init()
        },
        err => {
          this.$message({
            type: "warning",
            message: err.data.info
          });
        }
      );
    },
    init() {
      ajax(
        API.findManage,
        "get",
        {},
        d => {
          this.manages = d.data.data;
        },
        err => {
          alert(err.data.info);
        }
      );
    }
  },
  watch: {},
  computed: {},
  mounted() {
    this.init()
  }
};
</script>
<style lang="stylus" scoped>
@import '../../common/css/index.styl';
</style>